package com.py.framework.core.swagger;

import org.springframework.context.annotation.Bean;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
public class SwaggerConfig {

	@Bean
	public Docket createRestApi() {

		// ParameterBuilder tokenPar = new ParameterBuilder();
		// List<Parameter> pars = new ArrayList<Parameter>();
		// tokenPar.name("Token").description("令牌").modelRef(new
		// ModelRef("string")).parameterType("header")
		// .required(false).build();
		// pars.add(tokenPar.build());
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
				.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
				.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).build();
		// .globalOperationParameters(pars);

	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder().title("信用平台数据API文档").contact(new Contact("金电联行（江苏）信息技术有限公司", "", "")).version("1.0")
				.build();

	}
}
